home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / batch / xset260.zip / XSET.DOC < prev    next >
Text File  |  1992-08-01  |  21KB  |  570 lines

  1.     ┌──────────────────────────────────────────────────────────────┐
  2.     │    ENHANCED  SET  INSTRUCTION 2.60  -  (C) 1992 STERN Marc   │
  3.     └──────────────────────────────────────────────────────────────┘
  4.  
  5.  
  6.     All you always wanted to put in an environment variable and
  7.  never dare to ask DOS for...
  8.  
  9.         XSET: The way to easily write efficient batch files.
  10.  
  11.  
  12.     XSET allows you to put EVERYTHING you want in a variable of
  13.  the current environment and use it as if you gave it the value with
  14.  the standard DOS command 'SET'. You will be able to write very efficient
  15.  batch files including string manipulation, calculation,...
  16.  
  17.     XSET is the more powerful environment variable manipulation
  18.  program you never saw. It also has the easiest and most intuitive
  19.  user interface it is possible to write.
  20.  
  21.  
  22.  XSET is fully compatible with MS-DOS 5.0, DR-DOS 6.0, NDOS & 4DOS 4.0 .
  23.  
  24.  
  25.  
  26.  XSET has five major features:
  27.  ════════════════════════════
  28.  
  29.   - XSET permits to catch the output of any command (internal or external)
  30.     or program and put it into an environment variable.
  31.  
  32.   - XSET has several built-in commands to modify the output of a program
  33.     or a string given on the command-line (extract a part of a string,...)
  34.  
  35.   - XSET has a built-in full floating-point calculation functionalitie:
  36.                         ──────────────────────────────────────────────
  37.     You can make incremental loops, input a calculation string and
  38.     output a number,...
  39.  
  40.   - XSET can manage variable contents of more than 128 characters
  41.     (your path can now be as long as you want)
  42.  
  43.   - XSET has some other built-in commands to give you access to some
  44.     system datas (date, time, ...)
  45.  
  46.  
  47.  
  48.   * type XSET with no parameters to have the full description
  49.     of all functionalities (parameters and effects).    
  50.  
  51.  
  52.  
  53.  Example of use:
  54.  ══════════════
  55.  
  56.   Rem: in all the examples, the command XSET and the its built-in commands
  57.        are typed in uppercase and the environment variables names are
  58.        in lowercase. This is only for readability; when you type it,
  59.        you may mix lowercases and uppercase as you want.
  60.        The case is only significant for arguments strings you enter on the
  61.        command-line.
  62.  
  63.    
  64.   1)      XSET datvar DATE
  65.   Puts the date into the variable 'datvar'
  66.  
  67.   Type the command SET and you will see all the environment variables:
  68.           ...
  69.           COMSPEC=...
  70.           DATVAR=dd-mm-yy    (where dd,mm,yy are replaced by current
  71.                            day, month and year)
  72.           ...
  73.  
  74.   You can now use the variable 'datvar' in a batch file:
  75.           ECHO the date is %datvar%
  76.  
  77.  
  78.   2)      XSET name INPUT "Enter your name: "
  79.   Inputs a string from the keyboard (usual answer terminated by <Enter>)
  80.   and puts it into the variable 'name'.
  81.  
  82.   You can now use the variable 'name' in a batch file to enter
  83.   personal environment for each user:
  84.           ECHO Hello %name%, beginning the work
  85.           CD \%name%
  86.  
  87.     
  88.   3)  You can write a batch file with automatic loops
  89.  
  90.  
  91.        rem ------------------
  92.  
  93.        set loop=1
  94.  
  95.         :next
  96.  
  97.               .......
  98.               anything you want
  99.               .......
  100.  
  101.               XSET loop MATH %loop% + 1
  102.               if not %loop% == 20 goto next
  103.  
  104.        rem ------------------
  105.  
  106.  
  107.  
  108.   4)  You can write a batch file where the user may enter
  109.       a calculation and use it as a number
  110.  
  111.  
  112.       rem ------------------
  113.                                           
  114.       XSET calc INPUT "Enter your calculation: "
  115.  
  116.         XSET result MATH %calc%
  117.  
  118.         echo %calc% = %result%
  119.  
  120.        rem ------------------
  121.  
  122.  
  123.  
  124.  
  125.   5)  More complex example of a login procedure
  126.  
  127.           rem ---------------------- LOGIN.BAT --------------------------------
  128.  
  129.           echo off
  130.           cls
  131.  
  132.         :N
  133.           rem    Ask login name from keyboard
  134.           rem    ----------------------------
  135.           XSET login INPUT "Enter login name : "                            
  136.  
  137.           rem    Test if directory corresponding to login name already exist
  138.           rem    -----------------------------------------------------------
  139.           if exist c:\%login%\nul goto OK
  140.  
  141.           rem    Directory does not exist, ask to create it
  142.           rem    ------------------------------------------
  143.           echo:
  144.           echo Login '%login%' does not exist.
  145.           echo Do you want to create it? (Y/N)
  146.  
  147.           rem    Only "yYnN" keys are allowed
  148.           rem    ----------------------------
  149.           XSET ask KEY "yYnN"
  150.  
  151.         rem     Trick: if you use goto with a user input,
  152.         rem            you don't have to take care of charcter-case
  153.         rem            as DOS command.com is case-insensitive.
  154.         rem            Otherwise, transform the input in upper/lowercases.
  155.         rem     ----------------------------------------------------------
  156.         goto %ask%
  157.  
  158.         :Y
  159.           rem    Create directory
  160.           rem    ----------------
  161.           md c:\%login%
  162.  
  163.           :OK
  164.           set ask=
  165.  
  166.         rem     Go to user's directory and branch to personal
  167.         rem     batch file if any.
  168.         rem     ---------------------------------------------
  169.           cd \%login%
  170.           if exist autouser.bat autouser.bat
  171.  
  172.           rem -----------------------------------------------------------------
  173.  
  174.  
  175.   6) You may use only one password input for several network connections
  176.  
  177.           rem -----------------------------------------------------------------
  178.  
  179.           echo off
  180.           cls
  181.  
  182.           rem    Ask login name from keyboard
  183.           rem    ----------------------------
  184.           XSET login INPUT "Enter login name : "
  185.  
  186.           rem    Ask password from keyboard
  187.           rem    --------------------------
  188.           XSET passwd PASSWD "Enter password : "
  189.  
  190.           rem    Connection to several network nodes
  191.           rem    -----------------------------------
  192.         net use node1 ... %login% %passwd%
  193.         net use node2 ... %login% %passwd%
  194.         net use node3 ... %login% %passwd%
  195.  
  196.           rem    Overwrite variable containing password (to be sure)
  197.           rem    --------------------------------------
  198.         set passwd=something_longer_that_password_to_be_sure
  199.  
  200.           rem    Clear variable containing password (to free environment)
  201.           rem    ----------------------------------
  202.         set passwd=
  203.  
  204.           rem -----------------------------------------------------------------
  205.  
  206.   7)  And much more ...
  207.  
  208.  
  209.   Installation:
  210.   ════════════
  211.  
  212.      - XSET.EXE is ready to use; no installation,
  213.        but it is a SHAREWARE version.
  214.  
  215.      - To get a registered version of XSET, print the XSET.REG file,
  216.        fill it and send it to me; you will then receive the password
  217.        mandatory to use the program REGISTER.
  218.        You will receive each new upgrade for free!!!
  219.  
  220.  
  221.   Problems:
  222.   ════════
  223.  
  224.      - If the size of your environment space is not big enough,
  225.        you will receive an error message
  226.  
  227.              'XSET : not enough environment space.'
  228.                                             
  229.        This is not a bug, it is because the environment space
  230.        reserved for the variables is too small.
  231.        You must increase it by modifying the line 'SHELL=...'
  232.        in your CONFIG.SYS. By default, DOS reserves 256 bytes
  233.        environment space; this is generally insufficient.
  234.        Try 640 bytes (or more if you need it) by adding '/e:640'
  235.        at the line 'SHELL=...'
  236.  
  237.        ex:    SHELL=COMMAND.COM /E:640 /P
  238.  
  239.        
  240.        If this problem is encountered in a secondary shell
  241.        (i.e. you run the batch file from a menu that runs
  242.        a secondary shell) here is a way to work around the
  243.        problem (this is a DOS problem that could be avoided
  244.        by the program that runs the secondary shell):
  245.  
  246.        put in your AUTOEXEC.BAT a line such as:
  247.   SET TO_DELETE=something_very_long_to_be_sure_this_takes_very_much_space
  248.  
  249.        and, before using variables in the secondary shell delete this
  250.                                           ---------
  251.        variable with the command:
  252.   SET TO_DELETE=
  253.  
  254.  
  255.        An other way to work around this limitation is to patch the
  256.        COMMAND.COM; see file 'PATCH.DOS' for more explanation.
  257.  
  258.  
  259.      - If you use special characters like <>| you will have a problem
  260.        because COMMAND.COM interpretes these characters like redirection
  261.        commands before giving the control to the program you call.
  262.        This is a general DOS problem, but it is very easy to work around.
  263.  
  264.        ex:   XSET var MATH (1 + 3) > 2
  265.              Although you think you call XSET to check if 4 is greater
  266.              than 2, command.com interprets it as
  267.              "put into a file named 2 the result of 'XSET var MATH (1+3)'"
  268.  
  269.        You will have the same result with '<' and '|'.
  270.        The best way to ensure that all special characters you use
  271.        will be given 'as is' to the program you call (XSET or another one)
  272.        is to enclose your strings between double quotes:
  273.  
  274.        XSET var MATH "%loop% < (5 * 36)"
  275.        
  276.        Be careful that a string between quotes is interpreted as one
  277.        unique parameter for the program. So do not write
  278.               XSET var "MATH %loop% < 5"
  279.                               
  280.                               
  281.  
  282.      - If you want to use the character '%' in a batch file, remember
  283.        that this character is reserved for DOS environment variable;
  284.        so, if you want to use a 'real' % character, you have to write
  285.        '%%' in your batch file.
  286.  
  287.        ex: XSET var MATH "%other_var% %% 7"
  288.            This line in a batch file will put into variable 'var'
  289.            the result of '(contents of variable other_var) modulus 7'.
  290.  
  291.        Remark that the use of double quotes doesn't affect the way that
  292.        command.com interpretes the % character;
  293.        you must double the % character even if it is quoted.
  294.  
  295.  
  296.  
  297.  
  298.   Additional information:     32.2.427.98.52 (after 19h)
  299.   ══════════════════════   or 32.2.525.63.32 (work hours)
  300.  
  301.                   E-mail:     stern@mble.philips.be  (internet)
  302.                               see appendix for other networks
  303.  
  304.  
  305.  
  306.  
  307.              Syntax:     XSET  <dosvar>  COMMAND  [args..]
  308.  
  309. Commands    Arguments    Action and value assigned to <dosvar>
  310. --------    ---------    -------------------------------------
  311.  
  312. INPUT       [prompt]     echo <prompt> and read input from standard input
  313.                          ex:  XSET name INPUT Enter your name:
  314.  
  315. PASSWD      [prompt]     same as INPUT without echoing
  316.  
  317. APPEND      {string}     old value + <string>
  318.                          ex:  XSET path APPEND ;c:\msc600\bin;c:\msc600\binb
  319.                          Rem: this allow you to bypass the 128 characters
  320.                               limit of DOS
  321.  
  322. KEY         string       key pressed (must be in <string> if not empty)
  323.                          ex:  XSET k KEY 123aAbB
  324.                               only keys 123aAbB are allowed
  325.                          ex:  XSET k KEY
  326.                               all are allowed
  327.  
  328. LENGTH      {string}     number of characters in <string>
  329.  
  330. LEFT        n {string}   the leftmost <n> characters of <string>
  331.                          ex: XSET var LEFT 3 abcdef
  332.                              puts 'abc' in variable 'var'
  333.  
  334. MID         m n {string} the <n> characters in <string> starting from the <m>th
  335.  
  336. RIGHT       n {string}   the rightmost <n> characters of <string>
  337.  
  338. UPPER       {string}     uppercase <string>
  339.  
  340. LOWER       {string}     lowercase <string>
  341.                                       
  342. CHANGE      s1 s2 {s3}   change <s1> by <s2> in <s3>
  343.  
  344. SEARCH      str1 {str2}  portion of <str1> matching <str2>
  345.  
  346.         <str2> is a UNIX-like regular expression.
  347.         A regular expression is one or more occurrences of one or more
  348.         characters.
  349.         The following symbols are treated specially:
  350.         
  351.            ^  start of line             $  end of line
  352.            .  any character             \  quote next character
  353.            *  match zero or more time preceding character (or character set)
  354.            +  match one  or more time preceding character (or character set)
  355.            [] set of characters ('^' means non-inclusion, '-' means range)
  356.  
  357.               ex: [aeiou0-9]   match a, e, i, o, u, and 0 thru 9
  358.                   [^ae0-9]     match anything but a, e and 0 thru 9
  359.                   ^a           match any line beginning by 'a'
  360.                   v$           match any line ending    by 'v'
  361.  
  362.         XSET t SEARCH "^T.*K$"        "This line will be OK"
  363.         XSET t SEARCH "^T.*[1-9].*K$" "Warning: This line will not be OK"
  364.         XSET t SEARCH "^T.*K$"        "This line will not be OK!"
  365.         XSET t SEARCH "^T.*K"         "This line will be OK!"
  366.         XSET t SEARCH "T.*K$"         "Warning: This line will be OK"
  367.  
  368.  
  369. COUNT       {string}     the number of words in <string>
  370.  
  371. WORD        n {string}   pick the <n>-th word in <string>
  372.  
  373. LINE        n            read the <n>-th line from standard input
  374.  
  375. MATH        {expr}       result of calculation of expression <expr>
  376.                          mathematical operators: + - * / ()  on floats
  377.                                                           %  on integers
  378.                          logical operators:      = < > <= >= <>
  379.                                                  '*' is equivalent to 'and'
  380.                                                  '+' is equivalent to 'or'
  381.                          precedence: + and - have the highest precedence,
  382.                                      evaluation is performed from left to right.
  383.                          ex: XSET var MATH 3+(2*5) + %new% + (%loop% <= 5)
  384.  
  385. MIN      ┌{str1...strn}    minimum or maximum of numbers or strings list
  386. MAX      └{num1...numn}    (one string may not contain <space> or <tab>)
  387.                            ex: XSET var MIN 3.6 4 9.02
  388.                            ex: XSET var MAX 3.6 4 abc 3.9j
  389.                                                          
  390. DATE                     system date (dd-mm-yy)
  391.  
  392. DAY                      day of the month (1-31)
  393.  
  394. MONTH                    month number (1-12)
  395.  
  396. YEAR                     system year (4 digits)
  397.  
  398. DAYOFWEEK                day in the week ( 0 = sunday,... )
  399.  
  400. TIME                     system time (hh:mm:ss - 24h format)
  401.  
  402. HOUR                     system hour (0-24)
  403.  
  404. MINUTE                   system minutes (0-59)
  405.  
  406. SEC                      system seconds (0-59)
  407.  
  408. YYMMDD                   system date in 'yymmdd' format
  409.  
  410. DIFFDATE    date1 date2  number of days between date1 and date2 (date2 - date1)
  411.                          date format may be 'dd-mm-yy' or 'yymmdd'
  412.                          (may also be mixed)
  413.                          ex: XSET day_nb DIFFDATE 25-04-92 920508 will give
  414.                              14 days between 24 april and 8 march.
  415.  
  416. BYTEFREE    [drive]      number of bytes free on specified (or current) drive
  417.  
  418. DENSITY     [drive]      drive density (360, 720, 1200, 1440 or 0)
  419.  
  420. DIR         [drive]      current directory of <drive> or current drive
  421.  
  422. FPATH       {file}       full pathname of a filename
  423.  
  424. FDRIVE      {file}       drive of a filename
  425.  
  426. FDIR        {file}       drive & directory of a filename
  427.  
  428. FEXT        {file}       extension of a file name (no period included)
  429.  
  430. FNAME       {file}       name of a file without extension
  431.  
  432. FXNAME      {file}       name & extension of a file
  433.  
  434. FSIZE       {file}       size of a file
  435.  
  436. FDATE       {file}       date of a file (dd-mm-yy)
  437. FTIME       {file}       time of a file (hh:mm)
  438.  
  439. TRUENAME    {file}       full truename of a file
  440.  
  441.  
  442. ERRORLEVEL               errorlevel code of last command
  443.                          Rem: This command is only valid for
  444.                               - MS-DOS 3.20, 3.21, 3.30, 4.0, 4.01 & 5.0
  445.                               - NDOS 6.0
  446.                               Results are unpredictable under other OS
  447.                               or command processor like 4DOS, DR-DOS,
  448.                               PC-DOS,...
  449.                               
  450. VARCOPY     variable     contents of DOS environment variable 'variable'
  451.                          This is equivalent to 'set dosvar=%variable%'
  452.                          but allows to copy variables bigger than 128
  453.                          characters.
  454.  
  455.   [...] are optional arguments.
  456.  
  457.   If arguments {...} are missing, they are read from the standard input.
  458.   Non quoted arguments on command-line will be separated by 1 blank.
  459.  
  460.   Rem:    'XSET var'   is equivalent to  'XSET var INPUT'
  461.                                      or  'XSET var LINE 1'
  462.                    and is more performant.
  463.  
  464. XSET /CLEAR   will clear delete all variables from environment\r\n\n"
  465.  
  466. XSET /VIEW       will show all variables from environment
  467. Same as 'SET' command but show lines longer than 128 characters
  468.  
  469. XSET /VIEW var   will show content of variable 'var'
  470.                  This command is useful to use variables longer 
  471.                  than 128 characters.
  472.                  As COMMAND.COM trucates all lines longer than 128 
  473.                  characters, you will not be able to use a command like 
  474.                  'XSET newpath APPEND ";%path%"'
  475.                  if variable 'path' is longer than about 100 characters.
  476.  
  477.                  You can now type: 'XSET/VIEW path | XSET newpath APPEND'
  478.  
  479.  
  480. XSET /LOAD'   will load variables from standard input.
  481.               variables must have been saved with command 'XSET /VIEW'
  482. ex: save   variables with 'XSET /VIEW > SAVEFILE.VAR'
  483.     reload variables with 'XSET /LOAD < SAVEFILE.VAR'
  484.  
  485. XSET /SIZE   display environment size and free size (in bytes).
  486.  
  487.  
  488. You can exit the help screen at any time by hitting Escape or Ctrl-C.
  489.  
  490.  
  491.  
  492.  
  493.   APPENDIX:  E-mail address from other sites
  494.   ========
  495.  
  496.   Rem:   This list is obviously not complete and is given here only
  497.          as brute information. If you are connected to another network
  498.          or cannot reach internet with the following procedure, ask
  499.          your network manager.
  500.  
  501.  
  502.  
  503.   internet    :    stern@mble.philips.be
  504.  
  505.   bitnet      :    stern@mble.philips.be
  506.   aol         :    stern@mble.philips.be
  507.   att         :    internet!mble.philips.be!stern
  508.   applelink   :    stern@mble.philips.be@dasnet#
  509.   compuserve  :    >INTERNET:stern@mble.philips.be
  510.  
  511.   connect     :    DASNET
  512.                    (first line = "stern@mble.philips.be"@dasnet)
  513.  
  514.   easynet     :    stern@mble.philips.be                (from Ultrix)
  515.   easynet     :    stern%mble.philips.be@decwrl.dec.com (from Ultrix via IP)
  516.   easynet     :    DECWRL::"stern@mble.philips.be"      (from Ultrix via Decnet)
  517.   easynet     :    nm%DECWRL::"stern@mble.philips.be"   (from VMS)
  518.  
  519.   envoy       :    [RFC-822="stern(a)mble.philips.be"]INTERNET/TELEMAIL/US
  520.                    (for special characters, use @=(a), !=(b), _=(u), 
  521.                                                 any=(3 octal digits)
  522.  
  523.   fidonet     :    send to UUCP gateway with
  524.                    first line = "To: stern@mble.philips.be"
  525.  
  526.   geonet      :    DASNET (subject line = "stern@mble.philips.be!subject")
  527.   
  528.   gsfcmail    :    (SITE:SMTPMAIL,ID:<stern(a)mble.philips.be>)
  529.                 or (C:USA,A:TELEMAIL,P:SMTPMAIL,ID:<stern(a)mble.philips.be>)
  530.  
  531.   keylink     :    (C:au, A:telememo, P:oz.au, "RFC-822":
  532.   (continuing...)  "Marc Stern <stern(a)mble.philips.be>")
  533.                    (for special characters, use @=(a), !=(b), %=(p), "=(q)
  534.  
  535.   mci         :    To:  Marc Stern (EMS)
  536.                    EMS: internet
  537.                    MBx: stern@mble.philips.be
  538.  
  539.   nasamail    :    (site:smtpmail,id:<stern(a)mble.philips.be>)
  540.  
  541.   nsi         :    east::"stern@mble.philips.be"
  542.                 or dftnic::"stern@mble.philips.be"
  543.                 or nssdca::in%"stern@mble.philips.be"
  544.                 or jpllsi::"stern@mble.philips.be"
  545.  
  546.    omnet      :    type 'compose manual' at the prompt,
  547.                    choose 'Internet address' option from the menu,
  548.                    type 'stern@mble.philips.be'
  549.  
  550.   sinet       :    M_MAILNOW::M_INTERNET::"stern@mble.philips.be"
  551.                 or M_MAILNOW::M_INTERNET::mble.philips.be::stern
  552.  
  553.   span        :    AMES::"stern@mble.philips.be
  554.                 or HAMLET::"stern@mble.philips.be
  555.                 or IO::"stern@mble.philips.be
  556.                 or IUE::"stern@mble.philips.be
  557.                 or JPLLSI::"stern@mble.philips.be
  558.                 or NSFGW::"stern@mble.philips.be
  559.                 or NSSDCA::"stern@mble.philips.be
  560.                 or STAR::"stern@mble.philips.be
  561.  
  562.   sprintmail  :    (C:USA,A:TELEMAIL,P:INTERNET,"RFC-822":
  563.   (continuing...)  <stern(a)mble.philips.be>) DEL
  564.  
  565.   thenet      :    UTADNX::WINS%" stern@mble.philips.be "
  566.  
  567.   telemail    :    [INTERMAIL/USCISI]TELEMAIL/USA
  568.                    with first line = Forward: ARPA
  569.                    and second line = To: stern@mble.philips.be
  570.